# vim: ts=4 sw=4 syn=make
RELEASE_VER=0.2.0
RELEASE_PKG=ldapenter
RELNAME=${RELEASE_PKG}-${RELEASE_VER}
RELEASE_FILES=	ldapenter/attrdfn.c ldapenter/attributes.c \
				ldapenter/classes.c ldapenter/connect.c ldapenter/fetch.c \
				ldapenter/main.c ldapenter/search.c ldapenter/attrdfn.h \
				ldapenter/attributes.h ldapenter/classes.h \
				ldapenter/connect.h ldapenter/extern.h ldapenter/fetch.h \
				ldapenter/search.h ldapenter/BSDmakefile \
				ldapenter/ldapform.1 ldapenter/TODO ldapenter/LICENSE
PORTFILES=		port/Makefile port/pkg-descr port/distinfo port/pkg-plist
TARBALL=${.CURDIR}/releases/${RELEASE_PKG}-${RELEASE_VER}.tar.bz2

${TARBALL}: ${RELEASE_FILES}
	@mkdir -p ${TARBALL:H}
	@tmpdir=`mktemp -d rls.XXXXXX`; \
		echo "Using temporary directory: ${.OBJDIR}/$${tmpdir}"; \
		mkdir $${tmpdir}/${RELNAME}; \
		tar -C ${.CURDIR}/${RELEASE_PKG} -cf - ${RELEASE_FILES:T} | \
			tar -C $${tmpdir}/${RELNAME} -xf -; \
		echo "Replacing license in ${RELEASE_FILES:S/${RELEASE_PKG}/${RELNAME}/}"; \
		(cd $${tmpdir} && setlicense -f ${.CURDIR}/${RELEASE_PKG}/LICENSE \
			${RELEASE_FILES:S/${RELEASE_PKG}/${RELNAME}/} ); \
		tar -C $${tmpdir} -cvjf ${.TARGET} \
			${RELEASE_PKG}-${RELEASE_VER}; \
		rm -rf $${tmpdir}

release: ${TARBALL}
	@(cd ${.CURDIR}/releases && sha256  ${RELNAME}.tar.bz2) > ${.CURDIR}/port/distinfo
	@cat ${.CURDIR}/port/distinfo

port.shar: ${PORTFILES}
	@echo "Creating ${.TARGET}"
	@(cd ${.CURDIR}/port && shar ${.ALLSRC:T}) > ${.TARGET}

shar: port.shar
	@sha1 ${.ALLSRC}

clean:
	@rm -vf port.shar
